/* 新增CSS变量 */
:root {
    --primary-color: #2c3e50;       /* 主色调 */
    --secondary-color: #3498db;     /* 次色调 */
    --accent-color: #e74c3c;        /* 强调色 */
    --light-bg: #f8f9fa;           /* 浅色背景 */
    --dark-text: #2c3e50;          /* 深色文字 */
    --light-text: #95a5a6;         /* 浅色文字 */
    --shadow-color: rgba(0,0,0,0.1); /* 阴影颜色 */
}

/* 基础重置 */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    /* 设置背景图片 */
    background-image: url('/static/imgs/back.jpg');
    /* 设置背景图片不重复 */
    background-repeat: no-repeat;
    /* 设置背景图片覆盖整个页面 */
    background-size: cover;
    /* 背景图片固定，页面滚动时不移动 */
    background-attachment: fixed;
}

/* 头部样式 */
header {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow-color);
    margin-bottom: 2rem;
}

h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    text-align: center;
    margin: 0;
    padding: 1rem 0;
    position: relative;
}

h1::after {
    content: "";
    display: block;
    width: 60px;
    height: 3px;
    background: var(--secondary-color);
    margin: 1rem auto;
}

h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin: 2rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
}

/* 导航按钮组 */
.nav-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
}

/* 主按钮样式 */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 25px;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease;
}

.btn-primary:hover {
    opacity: 0.9;
}

/* 搜索表单 */
.search-container {
    display: flex;
    gap: 1rem;
    max-width: 600px;
    margin: 2rem auto;
}

#searchKeyword {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#searchKeyword:focus {
    border-color: var(--secondary-color);
    outline: none;
}

/* 分类标签 */
.category-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.category-buttons button {
    padding: 0.8rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    color: var(--dark-text);
    font-weight: 500;
    transition: all 0.3s ease;
}

.category-buttons button:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 3px 10px var(--shadow-color);
}

/* 博文卡片 */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.post-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: transform 0.3s ease;
}

.post-card:hover {
    transform: translateY(-5px);
}

.post-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 3px solid var(--light-bg);
}

.post-content {
    padding: 1.5rem;
}

.post-title {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-brief {
    color: var(--light-text);
    margin-bottom: 1.5rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .posts-grid {
        grid-template-columns: 1fr;
    }

    .category-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    header {
        padding: 1.5rem;
    }
}

/* 弹窗表单优化 */
.vertical-form-popup {
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.swal2-input {
    border-radius: 6px !important;
    transition: border-color 0.3s ease !important;
}

.swal2-input:focus {
    border-color: var(--secondary-color) !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}


/*新的*/
/* 新增顶部操作栏样式 */
.action-bar {
    display: flex;
    gap: 1.5rem;
    justify-content: flex-end;
    margin: 1rem 0 3rem;
    padding: 0 1rem;
}

/* 高级按钮样式 */
.action-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 4px 6px var(--shadow-color);
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
            120deg,
            transparent,
            rgba(255,255,255,0.3),
            transparent
    );
    transition: 0.5s;
}

.action-btn:hover::before {
    left: 100%;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3);
}

.action-btn:active {
    transform: translateY(1px);
}

/* 搜索容器升级 */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 2rem auto 3rem;
    width: 90%;
}

.search-container::before {
    content: "🔍";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
    z-index: 2;
}

#searchKeyword {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
}

#searchKeyword:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.2);
    background: white;
    outline: none;
}

#searchForm button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 25px;
    background: var(--secondary-color);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

#searchForm button:hover {
    background: var(--primary-color);
    transform: translateY(-50%) scale(1.05);
}

/*新表单*/

/* 高级表单样式 */
.vertical-form {
    display: grid;
    gap: 1.5rem;
    padding: 1rem;
}

.form-item {
    position: relative;
    --focus-color: var(--secondary-color);
}

.form-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
    opacity: 0.9;
    transition: all 0.3s ease;
}

.form-item input,
.form-item textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid rgba(44, 62, 80, 0.15);
    border-radius: 8px;
    background: rgba(255,255,255,0.95);
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.form-item input:focus,
.form-item textarea:focus {
    border-color: var(--secondary-color);
    background: white;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
    outline: none;
}

/* 浮动标签效果 */
.form-item.floating-label label {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    padding: 0 0.5rem;
    pointer-events: none;
    transition: all 0.3s ease;
}

.form-item.floating-label input:focus + label,
.form-item.floating-label input:not(:placeholder-shown) + label {
    top: 0;
    font-size: 0.9em;
    color: var(--secondary-color);
}

/* 动态边框动画 */
.form-item::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--secondary-color);
    transition: width 0.3s ease;
}

.form-item:focus-within::after {
    width: 100%;
}

/* 特别优化文本域 */
#postBrief {
    min-height: 100px;
    resize: vertical;
    padding: 1rem 1.2rem;
    line-height: 1.6;
    background-image: linear-gradient(
            to bottom,
            transparent 95%,
            rgba(44, 62, 80, 0.1) 95%
    );
    background-size: 100% 24px;
}

/* CKEditor 容器优化 */
.ck-editor__editable {
    min-height: 200px;
    border-radius: 8px !important;
    border: 2px solid rgba(44, 62, 80, 0.15) !important;
    transition: all 0.3s ease;
}

.ck-editor__editable:focus {
    border-color: var(--secondary-color) !important;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2) !important;
}

/* 表单图标装饰 */
.form-item[for="postTitle"]::before {
    content: "📌";
    position: absolute;
    right: 1rem;
    top: 50%;
    opacity: 0.3;
}

.form-item[for="postImageUrl"]::before {
    content: "🌄";
    position: absolute;
    right: 1rem;
    top: 50%;
    opacity: 0.3;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .vertical-form {
        gap: 1rem;
    }

    .form-item input,
    .form-item textarea {
        padding: 0.8rem;
    }
}

/*改表单*/

/* 修改弹窗容器样式 */
.swal2-container {
    --form-width: min(90vw, 800px); /* 动态宽度控制 */
}

.swal2-popup {
    width: var(--form-width) !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

/* 优化表单容器 */
.vertical-form {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0 1rem;
}

/* 强制表单项宽度自适应 */
.form-item input,
.form-item textarea,
.ck-editor__editable {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* 特别处理CKEditor容器 */
.ck-editor {
    width: 100% !important;
}

.ck-editor__editable {
    min-width: 100% !important;
    max-width: 100% !important;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .swal2-popup {
        --form-width: 95vw;
        padding: 1rem !important;
    }

    .vertical-form {
        gap: 1rem;
        padding: 0;
    }

    .form-item input,
    .form-item textarea {
        font-size: 14px;
    }
}

/* 防止横向滚动 */
body.swal2-shown {
    overflow: hidden;
}